CSCI E-92: Application Note 1 Notes on Using Console I/O under CodeWarrior Development Studio --------------------------------------------------------------- o getchar: No input is delivered to a program until the Enter key is pressed. o getchar: On input of an Enter key, first a carriage-return (0x0d) then a line-feed (0x0a) will be delivered to the calling program. o puts: In keeping with the C Standard, the I/O system always outputs a newline after the string argument. o fputs: In keeping with the C Standard, the I/O system never outputs a newline after the string argument. o putchar: When stdout is set to perform "line buffered" output (the default), no output actually occurs until a newline is output or until the internal buffer is full -- initially the buffer length is 64 characters. This buffering is mentioned in the "EWL C Reference Manual" in the chapter on stdio.h. Buffered characters that are not yet output can be forced to be output by calling fflush(stdout). o putchar: Output is "line buffered" unless the following call is made to indicate that output should be non-buffered: setvbuf(stdout, NULL, _IONBF, 0); This call to setvbuf should be made before your project performs any output to stdout. o putchar: Outputting either a carriage-return or a line-feed will actually perform the actions of both a carriage-return and a line-feed. o getchar: Input is broken after the first time the Enter key is pressed unless the following call is made: setvbuf(stdin, NULL, _IONBF, 0); This call to setvbuf should be made before your project performs any input from stdin. o getchar: There is no known way to input EOF (end-of-file) from stdin. o fprintf: For some reason, fprintf is declared in stdio.h only if the macro _EWL_OS_DISK_FILE_SUPPORT is non-zero. Because our hardware does not support disk files, fprintf is not declared. However, the fprintf *is* defined in the system library. You should add in the following declaration of fprintf *after* you include stdio.h: _EWL_IMP_EXP_C int _EWL_CDECL fprintf(FILE *_EWL_RESTRICT stream, const char *_EWL_RESTRICT format, ...) _EWL_CANT_THROW; o fprintf: Even after including the declaration above, fprintf seems to work only when it is called with only two actual paramters: the stream and the format string. If called with more than two actual parameters, the function is not found. An easy replacement for fprintf is to use sprintf, snprintf, vsprintf, or vsnprintf to produce formatted output using a format string into an output string and then to actually output the resultant string using fputs.